-- one_block
-- create by cheny3
-- 距离范围1格的执行转换

return {
    -- 触发
    trigger = function(pos)
        local grid = DungeonM.getGridByPos(pos);

        if grid.type ~= GRID_TYPE_TRANS_ELIMINATE or
            grid.state == GRID_STATE_DISABLE then
            -- trace("one_block", "不是转换消除格或已失效。");
            return false;
        end

        local coor = DungeonM.convertToCoor(pos);
        -- 距离自己1格的所有元素
        local idle = {};
        local index;
        for index = 1, DUNGEON_WIDTH * DUNGEON_HEIGHT do
            local c = DungeonM.convertToCoor(index);

            -- 有效范围内
            if math.abs(c.x - coor.x) + math.abs(c.y - coor.y) <= 1 then
                table.insert(idle, index);
            end
        end

        for _, index in pairs(idle) do
            TransEliminateM.exchangeElement(index);
        end

        return true;
    end,
};
